<?php
// +----------------------------------------------------------------------
// | ThinkPHP
// +----------------------------------------------------------------------
// | Copyright (c) 2007 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id: common.php 2601 2012-01-15 04:59:14Z liu21st $

/*
*	在图片所在目录下生成指定尺寸图片
*
*	@param $imgdir 图片路径
*	@param $maxWdith 图片宽度
*	@param $maxHeight 图片高度
*/
function getimg($imgdir, $maxWidth='999', $maxHeight='999'){
    $pos = strrpos($imgdir, '.');
	$new_imgdir = substr($imgdir,0,$pos).'_'.$maxWidth.'*'.$maxheight.substr($imgdir,$pos);

	$new_imgname = substr($new_imgdir, strrpos($new_imgdir, '/') );
	echo $new_imgdir;
	if( !file_exists($new_imgdir) )
	{
		import('ORG.Util.Image');
		$f = new Image();
		$res = $f->thumb($imgdir, $new_imgname, '', $maxWidth, $maxHeight);
		if($res!==false)
		{
			return true;
		}else{
			return false;
		}
	}
	else
	{
		return true;
	}

}


?>